Skip to content

feat(mcpx): resolve missing imports into dependency sets - #5637

Merged
dezren39 merged 1 commit into
mainfrom
queue/9003-1915-mcpx-resolve-imports
Nov 5, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/9003-1915-mcpx-resolve-imports

Conversation

@dezren39

@dezren39 dezren39 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Stage 1 graph
  retain resolved file edges
  resolve missing bare imports: explicit pin > nearest manifest > announced npm latest
  produce dependency set + isolated foreign-project subsets
  apply imports missing / cross-project / network / dynamic policies

Registers and wires the five script.imports* settings through CLI, exec service, daemon, and runner. Resolve is data-only: it does not install packages, rewrite manifests, or write lockfiles; stage 3 remains out of scope. Refs #1915.

Evidence

  • Before: preflight reported unresolved imports but discarded successful file edges and had no Resolve-stage dependency set or policy settings.
  • After: go test ./internal/preflight passes, including pin precedence, latest announcement, subset separation, and policy tests. go test ./internal/runner ./internal/execsvc ./internal/cli ./internal/daemon passes. Settings docs are regenerated.
  • The settings suite still reports three unrelated missing effect exemptions (proto.elicitationPerMinute, proto.samplingPerMinute, proto.samplingSessionPerMinute), reproduced on clean main.

Merge Danger

Door: two-way

Blast Radius: moderate — preflight report behavior and settings propagation; no package installation or project mutation.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 4, 2026 19:26
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8a3cbc63-99f6-4ea3-b6a7-cbde53bab0da
Commits

Reviewing files that changed from the base of the PR and between beaad88 and 9847d50.

Files selected for processing: 12
  • pkgs/mcpx/docs/configuration.md
  • pkgs/mcpx/internal/cli/commands.go
  • pkgs/mcpx/internal/cli/exec.go
  • pkgs/mcpx/internal/daemon/routes_exec.go
  • pkgs/mcpx/internal/execsvc/execsvc.go
  • pkgs/mcpx/internal/preflight/imports.go
  • pkgs/mcpx/internal/preflight/imports_test.go
  • pkgs/mcpx/internal/preflight/resolve.go
  • pkgs/mcpx/internal/preflight/resolve_test.go
  • pkgs/mcpx/internal/runner/runner.go
  • pkgs/mcpx/internal/settings/effect.go
  • pkgs/mcpx/internal/settings/registry.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T19:32:09.425639Z 9847d50 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9847d5062b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +382 to +385
name = strings.Join(parts[:2], "/")
rest := strings.TrimPrefix(spec, name)
if strings.HasPrefix(rest, "@") {
version = strings.SplitN(strings.TrimPrefix(rest, "@"), "/", 2)[0]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Separate version suffixes from scoped package names

For an explicit declaration such as @scope/pkg@1.2.3, joining the first two slash-separated components includes the version in name, leaving rest empty. A missing import of @scope/pkg therefore never matches that explicit pin and falls back to a manifest or npm latest, or fails when networking is disabled. The same parser also misreads versioned scoped npm targets loaded from deno.json. Split the version suffix out of the package component before constructing the scoped name.

Useful? React with 👍 / 👎.

Comment on lines +213 to +215
add := func(dst map[string]ResolvedPackage, p ResolvedPackage) {
if current, ok := dst[p.Name]; !ok || (current.Version == "" && p.Version != "") {
dst[p.Name] = p

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve explicit pins in foreign dependency sets

When a file edge enters a foreign project declaring foo@1, the boundary loop populates its dependency subset with that version before processing missing imports. If a missing import of foo has an explicit foo@2 declaration, the resolver selects version 2 but this first-write-wins helper discards it because version 1 is already present. Both isolate and merge modes consequently return the manifest version instead of the explicit pin, while the resolution diagnostic announces version 2. Allow the higher-precedence explicit resolution to replace the manifest-derived entry.

Useful? React with 👍 / 👎.

Comment on lines +132 to +134
if filepath.Ext(path) == ".jsonc" {
b = deps.StripJSONC(b)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize JSONC syntax in deno.json before parsing

For a project whose deno.json contains comments or trailing commas, default import preflight now fails even when every import resolves. Discovery reads the config, but this extension check skips normalization for deno.json, so json.Unmarshal fails and ResolveGraph returns a fatal manifest-reading error. The existing project-config loader in internal/runner/deps.go handles these files with deps.StripJSONC(raw) regardless of which Deno filename is used. Apply the same normalization here so previously accepted project configs do not prevent scripts from running.

Useful? React with 👍 / 👎.

Comment on lines +363 to +364
if err == nil && rel != ".." && !strings.HasPrefix(rel, ".."+string(filepath.Separator)) && (best == nil || len(m.Dir) > len(best.Dir)) {
best = m

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retain npm declarations alongside same-directory Deno configs

When a project contains both deno.json and package.json, discovery sorts the Deno config first, and this strict-depth comparison never considers the npm manifest at the same directory depth. For example, importing a foreign project with deno.json containing {} and dependencies declared in package.json produces an empty isolated dependency subset. Missing imports from that project also ignore its npm version declarations and instead query latest or fail with networking disabled. Combine the applicable same-directory declarations rather than letting the first manifest hide the other.

Useful? React with 👍 / 👎.

}

func nearestManifest(file string, manifests []PackageManifest) *PackageManifest {
path := fileURLToPath(file)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Decode file URLs before matching project directories

For a project directory containing spaces or other URL-escaped characters, fileURLToPath only removes the file:// prefix, so a graph URL such as file:///work/my%20project/main.ts does not match the discovered manifest directory /work/my project. This newly added filesystem lookup consequently ignores the project's declared versions, selecting npm latest or rejecting resolution when networking is disabled, and can omit foreign dependency subsets. Decode file URLs before converting them into filesystem paths, including the roots and edges already converted by ParseGraph.

Useful? React with 👍 / 👎.

@dezren39
dezren39 merged commit da38865 into main Nov 5, 2026
1 check passed
@dezren39
dezren39 deleted the queue/9003-1915-mcpx-resolve-imports branch November 5, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant